<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>二维数组创建和遍历</title>
	</head>
	<body>
		<script>
			var arr=[1,4,6];
			var sum=0;
			for (var i in arr) {
				sum=sum+arr[i];
			}
			var arr2=[[3,2,5],[7,4]];
			console.log("二维数组元素："+arr2);
			console.log("arr2[0][2]="+arr2[0][2]);
			
			var result=0;
		/*	for (var i in arr2) {
			//console.log(arr2[i]);
				for (var j in arr2[i]) {
				result+=arr2[i][j];
			    } 	
		    }*/
			for (var i = 0; i < arr2.length; i++) {
				for (var j = 0; j < arr2[i].length; j++) {
					result+=arr2[i][j]
				}
			}
			
			console.log(result);
			
		</script>
	</body>
</html>
